Derivation of Euler-Lagrange equation